#include<iostream>
#include<string>
#include<cstring>
using namespace std;
const int mod=11;
char M[]={'1','0','X','9','8','7','6','5','4','3','2'};
int v[]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
int sum;
int check(string s)
{
	for(int i=0;i<s.size()-1;i++)
	{
		char a=s[i];
		if(a<'0'||a>'9')
		return 0;
	}
	int res=0;
	for(int i=0;i<17;i++)
		res+=(s[i]-'0')*v[i]; 
	if(M[res%mod]==s[17])
	return 1;
	else
	return 0;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<17;i++)
	sum+=v[i];
	int cnt=0;
	while(n--)
	{
		string s;
		cin>>s;
		if(!check(s))
		{
			cout<<s<<endl;
			cnt++;
		}
	}
	if(!cnt)
	cout<<"All passed"<<endl;
	return 0;
}
